using NExt.Serialization;

namespace NExt.Core.Validator
{
    public class Range : ValidatorScript
    {
        private const string FUNCTION_NAME = "Range";

        private Range(params string[] parameterNames)
            : base(FUNCTION_NAME, parameterNames)
        {
        }

        public static Range Create(string message, object beginValue, object endValue)
        {
            string serializedMessage = JsonSerializer.Serialize(message);
            string serializedBeginValue = JsonSerializer.Serialize(beginValue);
            string serializedEndValue = JsonSerializer.Serialize(endValue);
            string parameter = string.Format("{0},{1},{2}", serializedMessage, serializedBeginValue, serializedEndValue);
            Range range = new Range(parameter);
            return range;
        }

        public static Range Create(object beginValue, object endValue)
        {
            return Create(null, beginValue, endValue);
        }

        public static Range Create(object beginValue)
        {
            return Create(null, beginValue, null);
        }
    }
}